package cs5226.util;

import java.sql.Timestamp;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import cs5226.util.Constants;

public class StringUtil {
	public static boolean isNullOrBlank(String s) {		
		return s == null || s.trim().length() == 0;
	}
	
	public static String formatDouble(double d) {
		return String.format("%.3f", d);
	}
	
	public static String formatTimestamp(Timestamp t) {
		return String.format("%1$td-%1$tB-%1$tY %1$tR", t);
	}
	
	public static Map<String, String> getThresholdsMap(){
		 Map<String, String> aMap = new  LinkedHashMap<String, String> ();
		 
		 aMap.put(Constants.SHAREPOOL_1, "Shared Pool Free %");
		 aMap.put(Constants.SHAREPOOL_2, "Library Cache Hit Ratio");
		 aMap.put(Constants.SHAREPOOL_3, "Library Cache Miss Ratio");
		 aMap.put(Constants.SHAREPOOL_4, "Row Cache Hit Ratio");
		 aMap.put(Constants.SHAREPOOL_5, "Row Cache Miss Ratio");
		 
		 
		 aMap.put(Constants.BUFFERCACHE_1, "Buffer Cache Hit Ratio");
		 
		 
		 aMap.put(Constants.REDOLOG_1, "Redo Allocation Hit Ratio (percentage of success)");;
		 aMap.put(Constants.REDOLOG_2, "Log file switch (checkpoint incomplete)");
		 
		 
		 aMap.put(Constants.MEMSORT_1, "Memory Sorts Ratio");
		 
		 aMap.put(Constants.ROLLBACK_1, "User Rollbacks Per Sec");		 
		 aMap.put(Constants.ROLLBACK_2, "User Rollbacks Percentage");
		 
		 return aMap;
	}
	
}
